<template>
  <table class="table table-bordered table-stripped">
    <!-- 表格标题区域 -->
    <thead>
      <tr>
        <th>#</th>
        <th>商品名称</th>
        <th>价格</th>
        <th>标签</th>
        <th>操作</th>
      </tr>
    </thead>
    <!-- 表格主体区域 -->
    <tbody>
      <tr v-for="(item, index) in arr" :key="item.id">
        <td>
          <slot :index="index">
            {{ index + 1 }}
          </slot>
        </td>
        <td>{{ item.goods_name }}</td>
        <td>
          <slot name="price" :price="item.goods_price">
            {{ item.goods_price }}
          </slot>
        </td>
        <td>
          <slot name="tags" :row="item">
            {{ item.tags }}
          </slot>
        </td>
        <td>
          <slot name="options" :row="item">
            <button class="btn btn-danger btn-sm">删除</button>
          </slot>
        </td>
      </tr>
    </tbody>
  </table>
</template>

<script>
export default {
  name: 'MyTable',
  props: {
    arr: {
      type: Array,
      required: true
    }
  }
}
</script>

<style scoped lang="less">
.my-goods-list {
  .badge {
    margin-right: 5px;
  }
}
</style>
